# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=chiron
pkgver=48.524abe1
pkgrel=3
groups=('blackarch' 'blackarch-scanner' 'blackarch-networking'
        'blackarch-exploitation' 'blackarch-proxy')
pkgdesc='An all-in-one IPv6 Penetration Testing Framework.'
arch=('any')
url='http://www.secfu.net/tools-scripts/'
license=('GPL2')
depends=('python2' 'python2-scapy' 'python2-ipaddr' 'python2-netaddr')
makedepends=('git')
source=("$pkgname::git+https://github.com/aatlasis/Chiron.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md \
    Chiron_Tutorial.pdf
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE Chiron_Tutorial.pdf

  cp -a bin/* lib/* files/ "$pkgdir/usr/share/$pkgname/"
  ln -s files/* "$pkgdir/usr/share/$pkgname/."

  _tools="chiron-combinations chiron-nd chiron-proxy chiron-scanner"
  _tools="$_tools chiron-attacks chiron-local-link"

  for tool in $_tools; do
    cat > "$pkgdir/usr/bin/$tool" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 ${tool/-/_}.py "\$@"
EOF
    chmod +x "$pkgdir/usr/bin/$tool"
  done

  chmod 755 "$pkgdir/usr/share/$pkgname/"*.py
}

